<?php
/**
 * Description of Mysql
 *
 * @author joona
 */
class Core_Mysql {
    //Placeholder for unprepared query
    private $rawQuery = '';
    //Placeholder for parameters
    private $parameters = array();

    /**
     *
     * @param $query
     */
    public function initQuery($query)
    {
        $this->rawQuery = $query;
    }

    /**
     *
     * @param <type> $nameOrIndex
     * @param <type> $value
     */
    public function setParameter($nameOrIndex, $value = null)
    {
        $this->parameters[$nameOrIndex] = $value;
    }

    /**
     *
     * @param <type> $listOfParameters
     */
    public function setParameters($listOfParameters)
    {
        foreach($listOfParameters as $nameOrIndex => $value)
            $this->setParameter($nameOrIndex, $value);

    }

    private function prepareQuery()
    {
        $names = array();
        $values = array();
        foreach($this->parameters as $name => $value)
        {
            $names[] = "{$name}";
            $values[] = mysql_real_escape_string($value);
        }

        try
        {

        }
        catch(Exception $e)
        {
            throw new Core_Mysql_Exception('Preparing query failed: '.$e->getMessage());
        }
    }

    public function reset()
    {
        $this->rawQuery = '';
        $this->parameters = array();
    }
}
class Core_Mysql_Exception extends Core_Exception{}